using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;

namespace Cdp
{

    public class Logger
    {
        public static bool EnableVerbose = false;

        public static void Verbose(string log)
        {
            if(EnableVerbose)
                WriteLogAsync("V", log);  
        }

        public static void Verbose(string format, params object[] args)
        {
            Verbose(string.Format(format, args));
        }

        public static void Information(string log)
        {
            WriteLogAsync("I", log);
        }

        public static void Information(string format, params object[] args)
        {
            Information(string.Format(format, args));
        }

        public static void Error(string log)
        {
            WriteLogAsync("E", log);
        }

        public static void Error(string format, params object[] args)
        {
            Error(string.Format(format, args));
        }

        private static void WriteLogAsync(string level, string log)
        {
            if (Debugger.IsAttached)
            {
                Debug.WriteLine(string.Format("{0} {1} {2} {3}", level, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffzzz"),
                            Thread.CurrentThread.ManagedThreadId, log));
            }
            else
            {
                Console.WriteLine(string.Format("{0} {1} {2} {3}", level, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffzzz"),
                            Thread.CurrentThread.ManagedThreadId, log));
            }
        }
    }
}